package com.siae.pojo;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("admin")
@Schema(name = "admin",description = "管理员信息")
public class Admin {
    @TableId(type = IdType.AUTO)
    private Integer id;
    @Schema(name = "adminName",description = "管理员账号")
    @TableField(value = "admin_name")
    private String adminName;
    @Schema(name = "password",description = "管理员密码")
    private String password;
    @Schema(name = "role",description = "管理员角色")
    private String role;
    @Schema(name = "email",description = "邮箱")
    private String email;
    @Schema(name = "status",description = "管理员账号状态 1：激活；2：禁用")
    private Integer status;
    @Schema(name = "addTime",description = "创建时间")
    @TableField(value = "add_time")
    private Date addTime;
    @Schema(name = "avatarUrl",description = "头像地址")
    @TableField(value = "avatar_url")
    private String avatarUrl;
    @Schema(name = "lastIp",description = "管理员登录ip")
    @TableField(value = "last_ip")
    private String lastIp;
    @Schema(name = "failedAttempts",description = "登录失败次数")
    @TableField(value = "failed_attempts")
    private Integer failedAttempts;
    @Schema(name = "lockedUntil",description = "账号锁定时间")
    @TableField(value = "locked_until")
    private String lockedUntil;
    @TableField(value = "is_del")
    private String isDel;

    /**
     * 管理员账号状态 1：激活；2：禁用
     * */
    public String getStatusStr(){
        if (status!=null){
            switch (status){
                case 1:
                    return "激活";
                case 2:
                    return "禁用";
            }
        }
        return "";
    }

}
